import request from '@/utils/request'

/**
 * 获取购物车列表
 */
export const getCartList = () => {
  return request({
    url: '/cart/list',
    method: 'get'
  })
}

/**
 * 添加商品到购物车
 */
export const addToCart = (data) => {
  return request({
    url: '/cart',
    method: 'post',
    data
  })
}

/**
 * 更新购物车商品数量
 */
export const updateCart = (data) => {
  return request({
    url: '/cart',
    method: 'put',
    data
  })
}

/**
 * 删除购物车记录
 */
export const deleteCart = (id) => {
  return request({
    url: `/cart/${id}`,
    method: 'delete'
  })
}

/**
 * 清空购物车
 */
export const clearCart = () => {
  return request({
    url: '/cart/clear',
    method: 'delete'
  })
}

/**
 * 获取购物车商品数量
 */
export const getCartCount = () => {
  return request({
    url: '/cart/count',
    method: 'get'
  })
}

/**
 * 批量删除购物车记录
 */
export const batchDeleteCart = (cartIds) => {
  return request({
    url: '/cart/batch',
    method: 'delete',
    data: cartIds
  })
}




